<template>
	<view class="pageBox">
		<!--发送红包-->

		<view class="item-box">
			<view class="title2">红包个数</view>
			<view class="flex align-center">
				<input placeholder="填写个数" v-model="num" class="money" type="number"/>
			</view>
		</view>
		
		<view class="item-box">
			<view class="title2">总金额</view>
			<view class="flex align-center">
				<input placeholder="￥0.00" v-model="money" class="money" type="number"/>
			</view>
		</view>
			
		<view class="item-box">
			<view class="title2">支付密码</view>
			<view class="flex align-center">
				<input placeholder="请输入支付密码" v-model="pay_pwd" class="money" type="password"/>
			</view>
		</view>
		
		<view class="footer">
			<view class="big-money">￥{{money || '0.00'}}</view>
			<view class="btn" @click="handerSubmitMore()">塞进红包</view>
		</view>
		
	</view>
</template>

<script>
export default {
	components: {
		
	},
	data() {
		return {
			num:'',
			money:'',
			content:'',
			data:{},
			type: '',
			id:0,
			pay_pwd:'',
		}
	},
	onLoad(options) {
		this.id = options.id;
		this.getPv();
	},
	onShow(){
		
	},
	methods: {
		getPv(){
			let that = this;
			
			uni.request({
				url: '/wanlshop/pay/getBalance',
				data: {},
				success: res => {
					res = res.res;
					if (res.code === 1) {
						that.data = res.data;
					}
				}
			});
		},
		handerSubmitMore(){
			//console.log("go submit", Number(this.money), Number(this.data.pv) );
			if(Number(this.num) <= 0){
				this.$wanlshop.msg('请输入红包个数');
				return false;
			}
			
			if(Number(this.money) <= 0){
				this.$wanlshop.msg('请输入总金额');
				return false;
			}

			if(!this.pay_pwd){
				this.$wanlshop.msg('请输入支付密码');
				return false;
			}
			
			// if(Number(this.money) > Number(this.data.pv)){
			// 	this.$wanlshop.msg('当前pv: '+this.data.pv+', pv不够哦~');
			// 	return false;
			// }
			
			uni.request({
				url: '/redenvelope/release',
				data: {
					type_id: this.id,
					num: this.num,
					money: this.money,
					pay_pwd: this.pay_pwd,
				},
				success: res => {
					res = res.res;
					if (res.code === 1) {
						let request = {
							num: this.num,
							money: this.money,
							id:res.data.id,
						};
						
						uni.setStorageSync('send-live-redpackage-more', request);
						
						uni.navigateBack({
							delta:1
						})
					}else{
						this.$wanlshop.msg(res.msg);
					}
				}
			});
			
		}
	}
}
</script>

<style scoped lang="scss">
.item-box{
	background-color: #ffffff;
	border-radius: 20rpx;
	margin: 20rpx 24rpx 0rpx 24rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 36rpx 28rpx;
	
	.money{
		text-align: right;
	}
	
	.content{
		width: 646rpx;
	}
}

.title2{
	font-size: 28rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #292929;
	width: 200rpx;
}

.chat-name{
	font-size: 28rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #999999;
}

.colorgrey{
	color: #999999;
}



.footer{
	display: flex;
	align-items: center;
	flex-direction: column;
	justify-content: center;
	margin-top: 80rpx;
	
}

.big-money{
	font-weight: bold;
	font-size: 60rpx;
	margin-bottom: 50rpx;
}

.btn{
	width: 300rpx;
	height: 80rpx;
	border-radius: 20rpx;
	background-color: red;
	color:white;
	display: flex;
	align-items: center;
	justify-content: center;
}
</style>